export class QuestionSubmitStatusEnum {
    private static instances: { [key: number]: QuestionSubmitStatusEnum } = {};

    public static readonly WAITING = new QuestionSubmitStatusEnum("等待中", 0);
    public static readonly RUNNING = new QuestionSubmitStatusEnum("判题中", 1);
    public static readonly SUCCESS = new QuestionSubmitStatusEnum("提交成功", 2);
    public static readonly FAILED = new QuestionSubmitStatusEnum("提交失败", 3);

    private constructor(private text: string, public value: number) {
        if (QuestionSubmitStatusEnum.instances[value]) {
            return QuestionSubmitStatusEnum.instances[value];
        }
        QuestionSubmitStatusEnum.instances[value] = this;
    }

    public static getValues(): number[] {
        return Object.values(QuestionSubmitStatusEnum.instances).map(item => item.value);
    }

    public static getEnumByValue(value: number): QuestionSubmitStatusEnum | null {
        return QuestionSubmitStatusEnum.instances[value] || null;
    }

    public getText(): string {
        return this.text;
    }

    public getValue(): number {
        return this.value;
    }
}

 